//
//  WKEditorView.m
//  WeKeTang
//
//  Created by ichina on 2017/9/1.
//  Copyright © 2017年 Dezhi Tiancheng Education Technology (Beijing) Co. Ltd. All rights reserved.
//

#import "WKEditorView.h"

@interface WKEditorView ()



@end

@implementation WKEditorView


- (instancetype)initWithFrame:(CGRect)frame{
    
  self =  [super initWithFrame:frame];
    
    if (self) {
        
        [self setupUI];
    }
    return self;
}

- (void)setupUI{
    
    [self addSubview:self.btnSelectAll];
    [self addSubview:self.btnDelete];
    
}
#pragma mark - 全选
- (void)selectAllAction:(UIButton*)sender{
    
    if ([self.delegate respondsToSelector:@selector(WKEditorView:btnSelectAllAction:)]) {
        [self.delegate WKEditorView:self btnSelectAllAction:sender];
    }
}
#pragma mark - 删除
- (void)deleteAction:(UIButton*)sender{
    
    if ([self.delegate respondsToSelector:@selector(WKEditorView:btnDeleteAction:)]) {
        [self.delegate WKEditorView:self btnDeleteAction:sender];
    }
    
}
- (void)layoutSubviews{
    [super layoutSubviews];
    
    [self.btnSelectAll mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.left.mas_equalTo(self).offset(10);
        make.top.mas_equalTo(self).offset(10);
        make.width.mas_equalTo((kDeviceScreenWidth - 25)*0.5);
        make.height.mas_equalTo(40);
    }];
    [self.btnDelete mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.right.mas_equalTo(self).offset(-10);
        make.top.mas_equalTo(self).offset(10);
        make.width.mas_equalTo((kDeviceScreenWidth - 25)*0.5);
        make.height.mas_equalTo(40);
      }];
}
- (UIButton *)btnSelectAll{
    
    if (_btnSelectAll == nil) {
        _btnSelectAll = [UIButton buttonWithType:UIButtonTypeCustom];
        [_btnSelectAll setTitle:@"全选" forState:UIControlStateNormal];
        [_btnSelectAll setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
        _btnSelectAll.backgroundColor = RGBColor(40, 188, 203);
        _btnSelectAll.titleLabel.font = [UIFont systemFontOfSize:16];
        _btnSelectAll.layer.cornerRadius = 3;
        _btnSelectAll.layer.masksToBounds = YES;
        [_btnSelectAll addTarget:self action:@selector(selectAllAction:) forControlEvents:UIControlEventTouchUpInside];
    }
    return _btnSelectAll;
}
- (UIButton *)btnDelete{
    
    if (_btnDelete == nil) {
        _btnDelete = [UIButton buttonWithType:UIButtonTypeCustom];
        [_btnDelete setTitle:@"删除" forState:UIControlStateNormal];
        [_btnDelete setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
        _btnDelete.backgroundColor = RGBColor(178, 178, 178);
        _btnDelete.layer.cornerRadius = 3;
        _btnDelete.layer.masksToBounds = YES;
        _btnDelete.titleLabel.font = [UIFont systemFontOfSize:16];
        [_btnDelete addTarget:self action:@selector(deleteAction:) forControlEvents:UIControlEventTouchUpInside];
    }
    return _btnDelete;
}
@end
